package com.example.myproject.redis.pubsub;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

//@Component
public class CleanEhcacheListener {
    @Autowired
    private RedisMessageListenerContainer container;

    @Autowired
    private MyListener cleanEhcacheSubscriber;

    @Autowired
    private ChannelTopic topic;

    @PostConstruct
    public void init() {
        container.addMessageListener(new MessageListenerAdapter(cleanEhcacheSubscriber),topic);
    }
}
